package com.qf.service.impl;

import com.qf.entity.Goods;
import com.qf.entity.GoodsSeckill;
import com.qf.feign.GoodsFeign;
import com.qf.service.SecKillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SecKillServiceImpl implements SecKillService {


    @Autowired
    private GoodsFeign goodsFeign;

    // 查询所有秒杀商品信息 - 不考虑分页
    @Override
    public List<Goods> goodsList() {
        //并不由后台服务去查询商品，而是去调用商品微服务完成这个功能
        return goodsFeign.goodsList();
    }


    @Override
    public int insertGoods(Goods goods, GoodsSeckill goodsSeckill) {
        //将秒杀信息封装到商品信息中
        goods.setGoodsSeckill(goodsSeckill);
        //通过feign调用商品服务进行商品添加
        return goodsFeign.goodsInsert(goods);
    }
}
